package it.com.cci.observer_pattern;

/**
 * @author Lefnmg
 * @Description:
 * @date 2018/3/25
 */
public class CurrentConditionsDisplay implements Observer, DisplayElement {
    private float temp;//温度
    private float humidity;//湿度
    private Subject weatherData;

    public CurrentConditionsDisplay(Subject weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("Current conditions : " + temp + "F degree and " + humidity + "% humidity");
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temp = temp;
        this.humidity = humidity;
        display();
    }
}
